#ifndef QLIFE_H
#define QLIFE_H

#include <QThread>
#include <QStringList>

class QGame;
class QColor;
class Dna;
//class QStringList;
/**
	@author Stefan Weigert <stefan.weigert@mailbox.tu-dresden.de>
*/
class QLife : public QThread
{
	Q_OBJECT
/*	Q_PROPERTY(bool isAlive READ isAlive)
	Q_PROPERTY(bool isPregnant READ isPregnant)
	Q_PROPERTY(Dna* dna READ getDna);
	Q_PROPERTY(float age READ getAge);
	Q_PROPERTY(float x READ getX);
	Q_PROPERTY(float y READ getY);
	Q_PROPERTY(float energy READ getEnergy);*/

	public:
		QLife ( QGame* parent, Dna* dna, long n, int width, int height );

		bool isAlive();
		bool isPregnant();

		long getId();
		int getWidth();
		int getHeight();
		int getPregnanceDuration();
		Dna* getDna();
		float getAge();
		float getX();
		void setX ( float x );
		float getY();
		void setY ( float y );
		float getEnergy();
		void setSelected ( bool select );

		virtual QString getName() = 0;

//		Q_INVOKABLE float eat();
		float eat();

		void update();

	signals:
		void birth ( Dna* dna );
		void config ( long id, QStringList data );

	protected:
		bool alive;
		bool pregnant;

		long id;
		int pregnanceDuration;

		float x, y;

		float energy;

		Dna* dna;

		virtual void think() = 0;
		virtual void collectData() = 0;
		virtual void run() = 0;
		virtual void initDecay() = 0;
		virtual void decay() = 0;

	private:
		int width;
		int height;

		float age;
};

#endif
